<template>
	<view class="all">
		<view class="top">
			<view class="top_box">
				<view class="top_box_text"> {{account_data}} </view>
				<view class="top_box_texts"> {{static_integral}} </view>
			</view>
			<view class="top_box">
				<view class="top_box_text"> 累计赠送 </view>
				<view class="top_box_texts"> {{money_log2}} </view>
			</view>
		</view>
		<view style="width: 100%;height: 20upx;background: #f5f5f5;"></view>
		<view class="list">
			<view class="list_top">
				<view class="list_top_text"> 流水记录 </view>
				<view class="box" v-for="(item,index) in list" :key="index" @click="record_details(item)">
					<view style="display: flex;justify-content: space-between;">
						<view>
							<view class="box_time" style="font-weight: bold;">{{item.title}}</view>
							<view class="box_time">{{item.addtime}}</view>
						</view>
						<view>
							<view class="box_time" style="text-align: right;" v-if="item.is == 1"> - <text style="color: blue;">{{item.money}}</text> </view>
							<view class="box_time" style="text-align: right;" v-if="item.is == 2"> + <text style="color: #ff0000;">{{item.money}}</text> </view>
							<view class="box_time">余额：{{item.sum}}</view>
						</view>
					</view>
					<!-- <view class="box_time" v-if="item.status == 0">状态:待审核</view>
					<view class="box_time" v-if="item.status == 1">状态:失败</view>
					<view class="box_time" v-if="item.status == 2">状态:成功</view> -->
				</view>
				<view v-if="list.length == 0" style="width: 100%;line-height: 100upx;height: 100upx;color: #999999;font-size: 28upx;text-align: center;">暂无更多数据</view>
			</view>
		</view>
		<!-- <view class="bottom_class">
			<view class="bottom_class_box" @click="conversion"> 兑换 </view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account_data:'赠送积分',
				static_integral:'',
				page:1,
				list:[],
				money_log2:''
			}
		},
		onShow() {
			this.page = 1
			this.user_assets_api()
			this.user_money_log3_api()
		},
		methods: {
			record_details(item) {
				uni.navigateTo({
					url:'../record_details/record_details?item='+ JSON.stringify(item) +'&account_data='+this.account_data
				})
			},
			//获取积分
			user_assets_api() {
				var that = this
				that.$request(that.$Api.user_assets_api, {
					access_token: uni.getStorageSync('access_token'),
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.static_integral = res.data.data.static_integral
						that.money_log2 = res.data.data.money_log2
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			user_money_log3_api() {
				var that = this
				that.$request(that.$Api.user_money_log3_api, {
					access_token: uni.getStorageSync('access_token'),
					page:that.page,
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.list = res.data.data.list
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			//互转
			conversion() {
				uni.navigateTo({
					url:'../conversion/conversion'
				})
			},
		},
		onReachBottom() {
			var that = this
			that.page++
			that.$request(that.$Api.user_money_log3_api, {
				access_token: uni.getStorageSync('access_token'),
				page:that.page,
			}, "POST").then(res => {
				if (res.data.code == 0) {
					if( res.data.data.list.length != 0 ) {
						that.list = that.list.concat(res.data.data.list)
					}
				} else {
					uni.showToast({
						title: res.data.msg,
						duration: 2000,
						icon: 'none'
					});
				}
			})
		}
	}
</script>

<style lang="less">
	page{
		.all{
			.bottom_class{
				.bottom_class_box{
					width: 700upx;
					line-height: 80upx;
					height: 80upx;
					text-align: center;
					font-size: 30upx;
					color: #fff;
					border-radius: 10upx;
					background: #333;
				}
				display: flex;
				justify-content: space-around;
				width: 700upx;
				padding: 10upx 25upx;
				background: #fff;
				border-top: 1upx solid #eee;
				position: fixed;
				bottom: 0upx;
			}
			.list{
				.list_top{
					.box{
						.box_time{
							font-size: 26upx;
							color: #999;
							padding: 10upx 0;
						}
						padding: 20upx 0;
						border-bottom: 1upx solid #eee;
					}
					.list_top_text{
						font-size: 32upx;
						font-weight: bold;
					}
					// display: flex;
					// justify-content: space-between;
				}
				width: 700upx;
				padding: 25upx 25upx 125upx 25upx;
			}
			.top{
				.tiixan{
					padding: 10upx 15upx;
					height: 30upx;
					line-height: 30upx;
					font-size: 28upx;
					font-weight: bold;
					border: 1upx solid #333;
					border-radius: 6upx;
				}
				.top_box{
					.top_box_texts{
						font-size: 26upx;
						color: #333;
						font-weight: bold;
					}
					.top_box_text{
						font-weight: bold;
						font-size: 26upx;
						color: #999;
					}
				}
				padding: 25upx;
				width: 700upx;
				display: flex;
				justify-content: space-between;
			}
		}
	}
</style>
